package com.wechat.back.controller;

import com.wechat.back.pojo.tools.Result;
import com.wechat.back.pojo.weather.WeatherForecast;
import com.wechat.back.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/weather")
public class WeatherController {
    @Autowired
    private WeatherService weatherService;

    @GetMapping("/forecast")
    public Result<List<WeatherForecast>> getWeatherForecast(@RequestParam String city) {
        List<WeatherForecast> weatherForecasts = weatherService.getWeatherForecast(city);
        return Result.success(weatherForecasts);
    }
}
